package cn.swing.his.affair.webapi.service.impl;

import cn.swing.his.affair.service.IAffairService;
import cn.swing.his.affair.webapi.mapper.AffairMapper;
import cn.swing.his.pojo.affair.dto.MedicalEquipmentDetailsDTO;
import cn.swing.his.pojo.affair.dto.MedicineDetailsDTO;
import cn.swing.his.pojo.affair.vo.*;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@DubboService
@Service
public class AffairServiceImpl implements IAffairService {

    @Autowired
    private AffairMapper affairMapper;
//    ---------------------------增


    /**
     * 新增药品信息
     *
     * @param medicineDetails
     * @return
     */
    @Override
    public Integer insertMedicineDetails(MedicineDetailsDTO medicineDetails) {
        return affairMapper.insertMedicineDetails(medicineDetails);
    }

    /**
     * 插入医疗设备信息
     *
     * @param medicalEquipmentDetails
     * @return
     */
    @Override
    public Integer insertMedicalEquipmentDetails(MedicalEquipmentDetailsDTO medicalEquipmentDetails) {
        return affairMapper.insertMedicalEquipmentDetails(medicalEquipmentDetails);
    }

    // 新增排班信息
    @Override
    public Integer insertScheduleInfo(Integer timeId, Integer dayId, Integer doctorId, Integer roomId) {
        return affairMapper.insertScheduleInfo(timeId, dayId, doctorId);
    }
    //    ---------------------------删

    // 根据ID删除药品信息
    @Override
    public Integer deleteMedicineDetailsById(Integer id) {
        return affairMapper.deleteMedicineDetailsById(id);
    }

    // 根据id删除设备信息
    @Override
    public Integer deleteMedicalEquipmentById(Integer id) {
        return affairMapper.deleteMedicalEquipmentById(id);
    }

    // 删除某一时段的所有排班信息
    @Override
    public Integer deleteScheduleInfoByTimeAndDayAndRoom(Integer timeId, Integer dayId, Integer roomId) {
        return affairMapper.deleteScheduleInfoByTimeAndDayAndRoom(timeId, dayId, roomId);
    }

    //    ---------------------------改

    /**
     * 根据ID修改药品信息
     *
     * @param medicineDetails
     * @return
     */
    @Override
    public Integer updateMedicineDetails(MedicineDetailsDTO medicineDetails) {
        return affairMapper.updateMedicineDetails(medicineDetails);
    }

    @Override
    public Integer updateMedicalEquipmentDetails(MedicalEquipmentDetailsDTO medicalEquipmentDetailsDTO) {
        return affairMapper.updateMedicalEquipmentDetails(medicalEquipmentDetailsDTO);
    }

    //    ---------------------------查

    /**
     * 获取药品列表
     *
     * @return 返回所有的药品信息
     */
    @Override
    public List<MedicineDetailsVO> getMedicineList() {
        return affairMapper.getMedicineList();
    }

    // 根据关键字查询药品信息
    @Override
    public List<MedicineDetailsVO> getMedicineByKeyword(String keyword) {
        return affairMapper.getMedicineByKeyword(keyword);
    }

    //    返回所有的设备信息
    @Override
    public List<MedicalEquipmentDetailsVO> getMedicalEquipmentList() {
        return affairMapper.getMedicalEquipmentList();
    }

    @Override
    public List<MedicalEquipmentDetailsVO> getMedicalEquipmentListByKeyword(String keyword) {
        return affairMapper.getMedicalEquipmentListByKeyword(keyword);
    }

    // 获取时间表列表
    @Override
    public List<ScheduleVO> getScheduleList() {
        return affairMapper.getScheduleList();
    }

    // 根据部门名称获取简单的医生信息
    @Override
    public List<DoctorSimpleVO> getDoctorSimpleByRoomId(Integer roomId) {
        return affairMapper.getDoctorSimpleByRoomId(roomId);
    }

    /**
     * 根据科室获取排班信息
     *
     * @param timeId
     * @param dayId
     * @param roomId
     * @return
     */
    @Override
    public List<Integer> getScheduleByTimeAndDayAndRoom(Integer timeId, Integer dayId, Integer roomId) {
        return affairMapper.getScheduleByTimeAndDayAndRoom(timeId, dayId, roomId);
    }


    // 获取某一时刻的排班人员姓名
    @Override
    public List<String> getScheduleUserName(Integer timeId, Integer dayId, Integer roomId) {
        return affairMapper.getScheduleUserName(timeId, dayId, roomId);
    }

    @Override
    public List<RoomSimpleVO> getRooms() {
        return affairMapper.getRooms();
    }

    @Override
    public Integer getScheduleStatus(Integer timeId, Integer dayId, Integer doctorId) {
        return affairMapper.getScheduleStatus(timeId, dayId, doctorId);
    }
}
